using DG.Tweening;
using UnityEngine;

public enum PivotAlign
{
    Left,
    Center,
    Right,
}

[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
[ExecuteInEditMode]
public abstract class MeshBase : MonoBehaviour
{
    protected MeshFilter mMeshFilter;
    private Mesh mInitMesh;
    
    protected Vector3[] mVector3s;
    protected int[] mTriangles;
    protected Vector2[] mUVs;
    
    private void Awake()
    {
        Init();
        InitMesh();
    }
    
    protected void Init()
    {
        mInitMesh = new Mesh();
        mMeshFilter = GetComponent<MeshFilter>();
        mMeshFilter.sharedMesh = mInitMesh;
    }
    
    protected virtual void InitMesh(){}
    protected virtual void UpdateShape(){}
    
    protected void UpdateMesh()
    {
        mMeshFilter.sharedMesh = mInitMesh;
        mMeshFilter.sharedMesh.vertices = mVector3s;
        mMeshFilter.sharedMesh.triangles = mTriangles;
        mMeshFilter.sharedMesh.uv = mUVs;
    }

    public abstract Tweener DoAnim(float endValue, float duration, float delay);

    protected void OnValidate()
    {
        InitMesh();
    }
}
